﻿using AiMoWindows.MainActions.AiActions;
using System.Windows;
using System.Windows.Input;

namespace AiMoWindows.Windows.AiAssistant.ViewModels
{
    class AiAssistantViewModel : ViewModelBase
    {
        public AiAssistantUIViewModel AiAssistantUI { get; }
        readonly Window mainWindow;
        readonly AiAskActions actions;
        public AiAssistantViewModel(Window owner)
        {
            actions = new AiAskActions(this);
            mainWindow = owner;
            AiAssistantUI = new AiAssistantUIViewModel(owner);
            AskAiCommmand = new RelayCommand(actions.AskAiButton_Click);
            AskCancelCommmand = new RelayCommand(actions.AskCancelButton_Click);
            SendSciptToAiCommand = new RelayCommand(actions.OpenScriptFormFromReplyCode);
            ClearAiReplyCommand = new RelayCommand(actions.ClearAiReply);
            AiAssistantUI.OnLanguageChanged += actions.AiAssistantUI_OnLanguageChanged;
        }
        public ICommand AskAiCommmand { get; }
        public ICommand AskCancelCommmand { get; }
        public ICommand SendSciptToAiCommand { get; }
        public ICommand ClearAiReplyCommand { get; }
        public void Init()
        {
            actions.InitReplyText();
        }
        public void ShowMessage(string message)
        {
            MessageBox.Show(mainWindow, message);
        }

        string _ReplyText = "";
        public string ReplyText
        {
            get => _ReplyText;
            set
            {
                _ReplyText = value;
                RaisePropertyChanged(nameof(ReplyText));
            }
        }
        string _UserInputText = "";
        public string UserInputText
        {
            get => _UserInputText;
            set
            {
                _UserInputText = value;
                RaisePropertyChanged(nameof(UserInputText));
            }
        }
    }
}